package com.hongyue.dey04;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class Demo {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket(9527);
        byte[] bys = new byte[1024];
        while (true) {
            DatagramPacket dp = new DatagramPacket(bys, bys.length);
            ds.receive(dp);
            InetAddress IP = dp.getAddress();
            String ID = IP.getHostName();
            String s = new String(bys, 0, dp.getLength());
            System.out.println("IP = " + IP);
            System.out.println("ID = " + ID);
            System.out.println("s = " + s);
        }
    }
}
